/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package spsutil;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author wesley
 */
public class EJBTestContext {

     private InitialContext initialContext;


     /***
      * server_url : 192.168.1.36:3306
      */
     public EJBTestContext(String server_url,String username,String password) throws NamingException{
            Properties p = new Properties();
            p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
            p.put("spssample", "new://Resource?type=DataSource");
            p.put("spssample.JdbcDriver", "com.mysql.jdbc.Driver");
            p.put("spssample.JdbcUrl", "jdbc:mysql://"+server_url+"/mytestdb");
            p.setProperty("spasample.UserName", username);
            p.setProperty("spasample.Password", password);
            p.setProperty("openejb.jndiname.format", "{deploymentId}/{interfaceClass}");
            p.put("spssample-ejbPU.hibernate.dialect", "commonUtils.MyMyDialect");
            //p.put("hyg-ejbPU.hibernate.dialect", "commonutility.HygHibernateDialect");
            initialContext = new InitialContext(p);
            System.out.println("Done Boot");

     }

     public EJBTestContext(String server_url,String username,String password,String dbname) throws NamingException{
            Properties p = new Properties();
            p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
            p.put("spssample", "new://Resource?type=DataSource");
            p.put("spssample.JdbcDriver", "com.mysql.jdbc.Driver");
            p.put("spssample.JdbcUrl", "jdbc:mysql://"+server_url+"/"+dbname);
            p.setProperty("spssample.UserName", username);
            p.setProperty("spssample.Password", password);
            p.setProperty("openejb.jndiname.format", "{deploymentId}/{interfaceClass}");





           

            
            p.put("spssample-ejbPU.hibernate.dialect", "commonUtils.MyMySQLDialect");
            initialContext = new InitialContext(p);

     }




    /**
     * @return the initialContext
     */
    public InitialContext getInitialContext() {
        return initialContext;
    }

    /**
     * @param initialContext the initialContext to set
     */
    public void setInitialContext(InitialContext initialContext) {
        this.initialContext = initialContext;
    }





}
